home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-coverdisks-
/
126a
/
football
/
user
/
updatescores.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
6KB
|
199 lines
/* ***********************************************************************
EXTRACT PROGRAM FOR FOOTBALL REXX SUITE
----------------------------------------
Copyright Mark Naughton 1996
Version Date History
--------------------------------------------------------------------------
1.0 260996 Created. Extracts results from schedule.learn and then
recreates schedule.df
1.1 270996 Tidied, with info messages. Changed to use new filenames.
'Teams.sflearn' is read in, the data is extracted, saved
and then sorted, reread and then updated in a much faster
way. Previous took 35 secs whereas this took 5 secs! Also
would not work because of problems in the loop as all
data has to be in order and the counter was only changed
when it put one in - SHOULD BE when there's a match
regardless of whether its been played or not.
1.2 121196 Updated to accept arguments so it can become a component
of FOOTBALL. Removed all messages.
131196 Added checks for files - if not found, exits without
a message.
201196 Added Iterate as teams can now play each other more
than twice so that other matches (to be played) aren't
written over.
**************************************************************************
Procedure
---------
1. Check files exist. Open Learn file and output file.
2. Read all data from Learn (without '*') and write to output file.
3. Close files.
4. Call external program to sort the output file.
5. Open output file and read into an array. Close file.
6. Delete output file.
7. Open Schedule file and read into an array. Close file.
8. Update Schedule array with data from Learn but only if a match hasn't
been played.
9. Write to Schedule file. Close file. Exit.
************************************************************************** */
ARG league_file
version = 1
input_file = '.sflearn'
input2_file = '.sf'
input3_file = '.df'
output_file = 'Data/Teams.temp'
autosched = "*AUTOSCHD="
separator = '*'
sdlines. = '???'
selines. = '???'
sdcount = 0
secount = 0
autos = 0
not_played = '__ __'
league_file = "Data/" || league_file
if exists(league_file || input_file) = 0 then exit
if exists(league_file || input2_file) = 0 then exit
if exists(league_file || input3_file) = 0 then exit
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(autosched,line) > 0 then
autos = 1
end
close(datafile)
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot open '"league_file || input3_file"' for reading."
exit
end
if autos = 1 then do
say
say "ERROR : (UpdateScores)"
say
say "This definition file, "league_file||input3_file", uses a"
say "schedule definition file. It is automatically scheduled so"
say "this will not work. Use 'UpdateScheduleScores' instead."
say
exit
end
if open(datafile,league_file || input_file,'r') then do
if open(datafile2,output_file,'w') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
if pos(separator,line) = 0 & words(line) > 0 then
writeln(datafile2,line)
end
close(datafile2)
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot create '"output_file"' for temporary sorting."
exit
end
close(datafile)
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot open '"league_file || input_file"' for reading."
exit
end
address command 'Exec/footsort T'
if open(datafile,output_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
if words(line) > 0 then do
secount = secount + 1
selines.secount = line
end
end
close(datafile)
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot open '"output_file"' for re-reading."
exit
end
address command 'delete >NIL: 'output_file
sdcount = 1
if open(datafile3,league_file || input2_file,'r') then do
do while ~eof(datafile3)
line = readln(datafile3)
line = strip(line)
sdlines.sdcount = line
sdcount = sdcount + 1
end
close(datafile3)
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot open '"league_file || input2_file"' for reading."
exit
end
i = 0
done = 0
do j=1 to sdcount
shome = strip(substr(sdlines.j,1,30))
saway = strip(substr(sdlines.j,41,30))
do i=1 to secount
home = strip(substr(selines.i,1,30))
away = strip(substr(selines.i,41,30))
if shome = home & saway = away & pos(not_played,sdlines.j) > 0 then do
sdlines.j = selines.i
say ">>"selines.i"<<"
k = k + 1
leave
end
end
if k = secount then leave
end
if open(datafile3,league_file || input2_file,'w') then do
do j=1 to sdcount-1
if j < sdcount-1 then
writeln(datafile3,sdlines.j)
else
writech(datafile3,sdlines.j)
end
close(datafile3)
end
else do
say
say "ERROR : (UpdateScores)"
say
say "Cannot open '"league_file || input2_file"' for writing."
exit
end
exit